package server

import (
	"context"
	"fmt"
	pb "longmen/server/pkg/protobuf"
	"strings"

	"longmen/server/pkg/common/api_models"
)

func (s *Server) AddSensitive(ctx context.Context, req *pb.AddSensitiveReq) (*pb.AddSensitiveResp, error) {
	oDirty := new(api_models.DirtyWords)
	sWords := req.GetWords()
	if len(sWords) == 0 {
		return nil, fmt.Errorf("empty string")
	}
	oDirty.OpType = int(req.OpType)
	sWords = strings.Replace(sWords, "，", ",", -1)
	oDirty.Words = strings.Split(sWords, ",")
	//err := cache.PushAny(oDirty, messages.DirtyWordsChannel)

	//if err != nil {
	//	return nil, err
	//}
	return &pb.AddSensitiveResp{Msg: "ok"}, nil
}
